<template>
  <div class="monitoringType">
    <el-card class="box-card">
      <div class="flexBetween">
        <div class="flex">
          <el-input placeholder="请输入" v-model="name" size="small"></el-input>
          <el-button type="primary" size="small" class="paddingLeft"
            >查询</el-button
          >
        </div>
        <div>
          <el-button
            size="small"
            type="primary"
            plain
            icon="el-icon-plus"
            @click="handleAdd"
            >新增</el-button
          >
        </div>
      </div>
      <el-table
        :data="tableData"
        :header-cell-style="{
          background: '#8595B9',
          color: '#fff',
          height: '44px',
        }"
        class="tableTop"
        height="100%"
      >
        <el-table-column type="expand">
          <template slot-scope="props">
            <el-table :show-header="false" :data="props.row.children">
              <el-table-column
                label="分类名称"
                prop="name"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                label="创建时间"
                prop="createTime"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column
                label="更新时间"
                prop="updateTime"
                show-overflow-tooltip
              ></el-table-column>
              <el-table-column label="操作" width="120">
                <template slot-scope="scope">
                  <el-tooltip content="修改">
                    <el-button
                      type="text"
                      icon="el-icon-edit-outline"
                    ></el-button>
                  </el-tooltip>
                  <el-tooltip content="删除">
                    <el-button
                      type="text"
                      icon="el-icon-delete"
                      style="color: red !important;"
                    ></el-button>
                  </el-tooltip>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column
          label="分类名称"
          prop="name"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="创建时间"
          prop="createTime"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="更新时间"
          prop="updateTime"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column label="操作" width="120">
          <template slot-scope="scope">
            <el-tooltip content="修改">
              <el-button
                type="text"
                icon="el-icon-edit-outline"
                @click="handelEdit(scope.row)"
              ></el-button>
            </el-tooltip>
            <el-tooltip content="删除">
              <el-button
                type="text"
                icon="el-icon-delete"
                style="color: red !important;"
              ></el-button>
            </el-tooltip>
          </template>
        </el-table-column>
      </el-table>
      <div class="page">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="100"
        ></el-pagination>
      </div>
    </el-card>
    <vx-popup
      :title="dialogTitle"
      width="700px"
      @close="cancelFormSubmit"
      :active.sync="dialogVisible"
      @confirmPopup="handleSubmit"
      @cancelPopup="cancelFormSubmit"
    >
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        label-width="100px"
        class="demo-ruleForm"
      >
        <el-form-item label="类型名称:" prop="name">
          <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>

        <el-form-item label="上级分类:" prop="type">
          <el-select
            v-model="ruleForm.type"
            placeholder="请选择"
            style="width: 100%;"
          >
            <el-option label="环境分类" value="huanjin"></el-option>
            <el-option label="大气分类" value="daqi"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </vx-popup>
  </div>
</template>
<script>
export default {
  data () {
    return {
      dialogTitle: "新增",
      dialogVisible: false,
      name: "",
      tableData: [
        {
          name: "环境荷载",
          createTime: "2020-10-10 13:12:00",
          updateTime: "2020-10-10 13:12:00",
          children: [
            {
              name: "大气环境",
              createTime: "2020-10-10 13:12:00",
              updateTime: "2020-10-10 13:12:00",
            },
          ],
        },
        {
          name: "环境荷载",
          createTime: "2020-10-10 13:12:00",
          updateTime: "2020-10-10 13:12:00",
          children: []
        },
        {
          name: "环境荷载",
          createTime: "2020-10-10 13:12:00",
          updateTime: "2020-10-10 13:12:00",
          children: []
        },
        {
          name: "环境荷载",
          createTime: "2020-10-10 13:12:00",
          updateTime: "2020-10-10 13:12:00",
          children: []
        },
      ],
      ruleForm: {
        name: "",
        type: ""
      },
      rules: {
        name: [{ required: true, message: "请输入类型名称", trigger: "blur" }],
        type: [
          { required: true, message: "请选择上级分类", trigger: "change" },
        ]
      },
    };
  },
  watch: {

  },
  methods: {
    // 新增弹框
    handleAdd () {
      this.dialogTitle = "新增";
      this.dialogVisible = true;
    },
    // 修改弹框
    handelEdit () {
      console.log(1111);
      this.dialogTitle = "修改";
      this.dialogVisible = true;
    },
    cancelFormSubmit () {
      this.dialogVisible = false;
    },
    handleSubmit () { },
    component () { },
  },
};
</script>
<style scoped lang="scss">
/deep/.el-table__header tr,
.el-table__header th {
  padding: 0;
  height: 44px;
}
/deep/.el-table__expanded-cell {
  padding: 0 0 0 50px;
}
.monitoringType {
  .box-card {
    .flexBetween {
      display: flex;
      justify-content: space-between;
      .paddingLeft {
        margin-left: 20px;
      }
    }
    .tableTop {
      margin-top: 20px;
    }

    .page {
      margin-top: 20px;
      text-align: center;
    }
  }
}
</style>
